import { ObjCreate } from "../../common/ObjCreate";
import { LoaderHelp } from "../../../../common/display/LoaderHelp";
import { ResFileConst } from "../../../resource/ResFileConst";
import { MountStartsBallSp } from "./MountStartsBallSp";
import { MountStartsEvents } from "../events/MountStartsEvents";
import { ItemData } from "../../../resource/info/ItemData";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../../resource/ImagesConst";
import { FilterConst } from "../../../../component/gconst/FilterConst";
type int = number;
//class MountStartsBallAlbum
    
    export  class MountStartsBallAlbum /* flash.display.Sprite */
    {
        constructor()
        {
            
            this._ballArr = [];
            this.initView();
            return;
        }

        /* internal  */initView(): void
        {
            var loc1=null;
            this._ballLineBm = ObjCreate.createBitmap("", 25, 18, this);
            LoaderHelp.addResCallBack(ResFileConst.mountStarts, this.onLoadBmResource);
            this._ballContain = new Object /* flash.display.Sprite */();
            addChild(this._ballContain);
            var loc2=1;
            while (loc2 < 10) 
            {
                loc1 = new MountStartsBallSp(loc2);
                loc1.open = true;
                loc1.addEventListener(MountStartsEvents.ONBALLSELECT, this.onballselect);
                if (loc2 != 1) 
                {
                    if (loc2 != 2) 
                    {
                        if (loc2 != 3) 
                        {
                            if (loc2 != 4) 
                            {
                                if (loc2 != 5) 
                                {
                                    if (loc2 != 6) 
                                    {
                                        if (loc2 != 7) 
                                        {
                                            if (loc2 != 8) 
                                            {
                                                loc1.x = 330;
                                                loc1.y = 3;
                                            }
                                            else 
                                            {
                                                loc1.x = 292;
                                                loc1.y = 29;
                                            }
                                        }
                                        else 
                                        {
                                            loc1.x = 249;
                                            loc1.y = 12;
                                        }
                                    }
                                    else 
                                    {
                                        loc1.x = 209;
                                        loc1.y = 20;
                                    }
                                }
                                else 
                                {
                                    loc1.x = 168;
                                    loc1.y = 29;
                                }
                            }
                            else 
                            {
                                loc1.x = 129;
                                loc1.y = 3;
                            }
                        }
                        else 
                        {
                            loc1.x = 88;
                            loc1.y = 15;
                        }
                    }
                    else 
                    {
                        loc1.x = 46;
                        loc1.y = 28;
                    }
                }
                else 
                {
                    loc1.x = 4;
                    loc1.y = 11;
                }
                this._ballContain.addChild(loc1);
                this._ballArr.push(loc1);
                ++loc2;
            }
            return;
        }

        public updateInfo(arg1: ItemData, arg2: Boolean): void
        {
            var loc1=0;
            var loc2=0;
            this._mountIdata = arg1;
            if (this._mountIdata.itemExInfo.mount_rein >= 2) 
            {
                loc1 = 0;
                while (loc1 < this._ballArr.length) 
                {
                    if (loc1 < this._mountIdata.itemExInfo.m_stLv.length) 
                    {
                        this._ballArr[loc1].open = true;
                        this._ballArr[loc1].setTargetColor(this._mountIdata.itemExInfo.m_stTa[loc1]);
                    }
                    else 
                    {
                        this._ballArr[loc1].open = false;
                    }
                    ++loc1;
                }
                if (arg2 && this._mountIdata.itemExInfo.m_stLv.length > 0) 
                {
                    this._ballArr[(this._mountIdata.itemExInfo.m_stLv.length - 1)].seleted = true;
                }
            }
            else 
            {
                loc2 = 0;
                while (loc2 < this._ballArr.length) 
                {
                    this._ballArr[loc2].open = false;
                    ++loc2;
                }
            }
            return;
        }

        protected onballselect(arg1: MountStartsEvents): void
        {
            this.updateSeleted((arg1.index - 1));
            this.dispatchEvent(new MountStartsEvents(MountStartsEvents.TWEENING_COMPLETE, this._selectIndex));
            return;
        }

        public updateSeleted(arg1: int): void
        {
            if (this._selectIndex > -1) 
            {
                if (this._selectIndex == arg1) 
                {
                    return;
                }
                (this._ballArr[this._selectIndex] as MountStartsBallSp).seleted = false;
            }
            this._selectIndex = arg1;
            (this._ballArr[this._selectIndex] as MountStartsBallSp).seleted = true;
            return;
        }

        /* internal  */onLoadBmResource(): void
        {
            this._ballLineBm.bitmapData = GlobalClass.getBitmapData(ImagesConst.mountStartsTargetLine);
            return;
        }

        public get selectIndex(): int
        {
            return this._selectIndex;
        }

        public clean(): void
        {
            var loc1=0;
            while (loc1 < this._ballArr.length) 
            {
                this._ballArr[loc1].open = false;
                ++loc1;
            }
            this.mouseChildren = false;
            this.mouseEnabled = false;
            this.filters = [FilterConst.colorFilter];
            return;
        }

        /* internal */ /* var */_ballLineBm: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_ballArr: Array<any>;

        /* internal */ /* var */_ballContain: Object /* flash.display.Sprite */;

        /* internal */ /* var */_selectIndex: int=-1;

        /* internal */ /* var */_mountIdata: ItemData;
    }
